const mongoose = require('mongoose');

const userSchema = new mongoose.Schema({
  username: {
    type: String,
    required: true,
    unique: true
  },
  password: {
    type: String,
    required: true
  },
  email: {
    type: String,
    default: ''
  },
  phone: {
    type: String,
    default: ''
  },
  nickname: {
    type: String,
    default: ''
  },
  role: {
    type: String,
    // enum: ['admin', 'user'],
    // default: 'user'
  },
  roleName: {
    type: String
  },
  status: {
    type: Number,
    default: 1
  },
  createTime: {
    type: Date,
    default: Date.now
  },
  updateTime: {
    type: Date,
    default: Date.now
  },
  lastLoginTime: {
    type: Date
  },
  lastLoginIp: {
    type: String
  }
});

module.exports = mongoose.model('User', userSchema);
